<template>
	<view>

		<view class="income_wrap noBackground">
			<view class="order_tool_bar">
				<view class="tool_menu">
					<u-row gutter="16">
						<u-col span="3" style="position: relative;">
							<view class="demo-layout-top" @click="Topage('/subpackageA/pages/PingTaiRule/PingTaiRule')">
								<image :src="BestImgUrl+'pingtaiguize01.png'" mode="aspectFill"></image>
								<view class="menu_name">平台规则</view>
							</view>
						</u-col>
						<u-col span="3" style="position: relative;">
							<view class="demo-layout-top" @click="Topage('/subpackageA/pages/BeginnersGuide/BeginnersGuide')">
								<image :src="BestImgUrl+'xinshouzhian02.png'" mode="aspectFill"></image>
								<view class="menu_name">新手指南</view>
							</view>
						</u-col>
						<u-col span="3" style="position: relative;">
							<view class="demo-layout-top" @click="Topage('/subpackageA/pages/yhxy')">
								<image :src="BestImgUrl+'yongxieyi03.png'" mode="aspectFill"></image>
								<view class="menu_name">用户协议</view>
							</view>
						</u-col>
						<u-col span="3" style="position: relative;">
							<view class="demo-layout-top" @click="Topage('/subpackageA/pages/yszc')">
								<image :src="BestImgUrl+'yinsixieyi04.png'" mode="aspectFill"></image>
								<view class="menu_name">隐私政策</view>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
		</view>

		<view class="gonggao_list">
			<view class="gonggao_list_box">
				<view class="list_box_title">猜你想问</view>
				<view v-if="newslist.length != 0">
					<view class="list_box_item" v-for="(item,index) in newslist" :key="index" @click="Todetails(item)">
						<view>{{item.title}}</view>
						<!-- <view>{{item.create_time}}</view> -->
					</view>
				</view>
				<view class="noData_box" v-else>
					<image src="/static/images/noData.png" mode="widthFix"></image>
					<view>暂无数据</view>
				</view>
			</view>
		</view>
		
		
		<!--客服-->
		<!-- #ifdef APP-PLUS || H5 -->
		<view class="kefu_Box" @click="callservice()">
			<image class="kefu_icon" :src="BestImgUrl+'kefu_icon.png'"></image>
		</view>
		<!-- #endif -->
		
		<!-- #ifdef MP-WEIXIN -->
		<view class="kefu_Box">
			<button type="default" open-type="contact">
				<image class="kefu_icon" :src="BestImgUrl+'kefu_icon.png'"></image>
			</button>
		</view>
		<!-- #endif -->
		

	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				BestImgUrl: app.globalData.imgurlBwc,
				list: [],
				current: 0,
				typeid: '',
				newslist: [],
				
				pageSize: 1,
				pageNum: 10,
			}
		},
		onLoad(options) {
			let that = this
			let token = uni.getStorageSync('token')
			
			this.gettype()
			// #ifdef MP-WEIXIN
			console.log('二维码信息', options)
			//绑定推荐人-小程序端
			if (JSON.stringify(options) != '{}') {
				let pdi = {
					parent_id: options.scene,
					reseller_id: {
						reseller_id: uni.getStorageSync('reseller_id') || ''
					}
				}
				app.globalData.bindSaveParentId(pdi);
			} else {
				//options为空
			}
			
			
			
			
			
			
			
			if (!token) {
				uni.login({
					provider: 'weixin',
					success: function(login_res) {
						that.$api.wxminiappLogon({
							code: login_res.code,
							avatar: that.$store.state.baseUrl + '/public/uploads/h5/me/Group-33475.png', //	是	string	用户头像
							nickname: '领食惠探店用户',
							username: '',
							appid: uni.getStorageSync('miniProgramAppId')
						}).then(res => {
							//console.log('微信小程序登录', res)
							uni.setStorageSync('token', res.data.result.token)
							setTimeout(() => {
								that.$api.GetuserInfo({
									
								}).then(res => {
									uni.setStorageSync('userinfo', res.data.result)
								}).catch(err => {
									
								})
							}, 500);
						}).catch(err => {})
					},
					fail: function(err) {}
				});
			} else {
				
			}
			
			// #endif
		},
		//下拉刷新
		onPullDownRefresh() {
			let that = this
			that.pageSize = 1
			that.pageNum = 10
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1500);
		},
		//触底加载
		onReachBottom() {
			let that = this
			that.loadText.nomore = '没有更多了'
			that.Bottomingrefresh = false
		
			this.loadingstatus = 'loading';
			setTimeout(function() {
				that.pageSize++;
				
				that.getlist()
				uni.hideNavigationBarLoading()
			}, 500);
		},
		methods: {
			Topage(url) {
				uni.navigateTo({
					url: url
				})
			},
			gettype() {
				let that = this
				that.$api.getNoticetype({
			
				}).then(res => {
					//console.log(res.data.result)
					that.list = res.data.result
					//设为默认第一个
					let tid = res.data.result[0].id
					that.typeid = tid
					that.getlist()
				}).catch(err => {
					uni.showToast({
						title: err.data.msg,
						icon: 'none',
						duration: 2000
					});
				})
			},
			getlist() {
				let that = this
				that.$api.getBzZxinList({
					page: that.pageSize, //	否	int	页码 默认第一页
					limit: that.pageNum, //	否	int	每页条数 默认10条
					//type_id: that.typeid //否	int	全部 默认不传 公告类型ID
				}).then(res => {
					console.log(res.data.result)
					//that.newslist = res.data.result
					
					if (that.pageSize != 1) {
						if (res.data.result.length != 0) {
							that.loadingstatus = 'loading';
							that.newslist = that.newslist.concat(res.data.result)
						} else {
							that.newslist = []
						}
					} else {
						that.newslist = res.data.result
					}
					
				}).catch(err => {
					uni.showToast({
						title: err.data.msg,
						icon: 'none',
						duration: 2000
					});
				})
			},
			Todetails(data) {
				uni.navigateTo({
					url: '/subpackageC/pages/rulepage/noticDetails/noticDetails?id=' + data.id
				})
			},
			//拉起客服
			callservice() {
				let data = uni.getStorageSync('customerServiceData')
				// #ifdef H5
				window.location.href = data.h5.url
				// #endif
				
				// #ifdef APP-PLUS
				let appurl = data.app.url
				uni.navigateTo({
					url: '/pages/Webview/Webview?url=' + encodeURIComponent(JSON.stringify(appurl))
				})
				// #endif
			
			},
			// 小程序跳转企业客服
			toCustomerServicePages: function() {
				try {
					let data = uni.getStorageSync('customerServiceErWeima')
					console.log('客服链接',data)
					
					wx.openCustomerServiceChat({
						extInfo: {
							url: data.path //客服ID
						},
						corpId: data.appid, //企业微信ID
						success(res) {}
					})
				} catch (error) {
					showToast("请更新至微信最新版本")
				}
			},
			
			
			
			
			
			
			onShareAppMessage() {
				let that = this
				let myid = uni.getStorageSync('userinfo').id
				
				return {
				  title: '帮助中心',
				  path: '/subpackageC/pages/rulepage/rulepage?parent_id=' + myid,
				  imageUrl: that.BestImgUrl + 'yiyuanchiwaimai.png',
				  type: 0,
				  success: (res) => {
				    //console.log("转发成功", res);
				  },
				  fail: (res) => {
				    //console.log("转发失败", res);
				  } 
				}
			},
			onShareTimeline() {
				let that = this
				let myid = uni.getStorageSync('userinfo').id
				
				return {
				  title: '帮助中心',
				  query: '/subpackageC/pages/rulepage/rulepage?parent_id=' + myid,
				  imageUrl: that.BestImgUrl + 'yiyuanchiwaimai.png',
				  success: (res) => {
				    //console.log("转发成功", res);
				  },
				  fail: (res) => {
				    //console.log("转发失败", res);
				  } 
				}
			},
			
			
			
			
			
			
			
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f6f6f6;
	}
	.noData_box {
		margin: 100rpx 0 200rpx 0;
		text-align: center;
		color: #999;
		image {
			width: 340rpx;
		}
	}
	.gonggao_list {
		background-color: #f6f6f6;
		padding: 30rpx;

		.gonggao_list_box {
			background-color: #ffffff;
			padding: 0 30rpx 14rpx 30rpx;
			border-radius: 20rpx;

			.list_box_title {
				font-weight: bold;
				font-size: 32rpx;
				padding: 30rpx 0 10rpx 0;
			}

			.list_box_item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 30rpx 0;
				border-bottom: 1px solid #E4E4E4;

				view:nth-child(1) {
					flex: 1;
					margin-right: 10rpx;
					word-break: break-all;
					display: -webkit-box;
					-webkit-line-clamp: 1;
					-webkit-box-orient: vertical;
					overflow: hidden;
				}

				view:nth-child(2) {
					color: #999;
				}
			}
			.list_box_item:last-child {
				border-bottom: none;
			}
		}
	}

	.income_wrap {
		background-color: #fff;
		padding: 30rpx;
		margin: 0 0 0 0;

		.order_tool_bar {

			.tool_title {
				padding: 20rpx 0 0 0;
				font-weight: bold;
				margin-top: 10rpx;
			}

			.tool_menu {
				margin-top: 0;
				position: relative;

				.demo-layout-top {
					text-align: center;
					font-size: 24rpx;

					image {
						width: 96rpx;
						height: 96rpx;
					}

					.menu_name {
						font-size: 28rpx;
						margin-top: 16rpx;
					}
				}
			}
		}
	}
</style>